export function successOrError(res) {
    if (res.data.code == "0") {
        this.$message({
            type: "success",
            message: res.data.message,
        });
        this.$refs.form.resetFields();
        this.$emit("click", "success");
    } else {
        this.$message({
            type: "error",
            message: res.data.message,
        });
    }
}

export function download(res, name="excel", format="xls") {
    let reader = new FileReader();
    reader.readAsDataURL(res.data);
    reader.onload = function(e) {
        const downloadElement = document.createElement('a');
        downloadElement.download = name + "." + format;
        downloadElement.href = e.target.result;
        downloadElement.click();
        downloadElement.remove();
    }
}

export function noop() {
    
}